const validatePass = async (_rule, value) => {
  if (value !== '' && value.length < 6) {
    return Promise.reject('密码不能少于6位')
  }
  return Promise.resolve()
}
const validateCode = async (_rule, value) => {
  if (value !== '' && value.length !== 4) {
    return Promise.reject('验证码必须为4位')
  }
  return Promise.resolve()
}
export const rules = {
  username: [
    {
      required: true,
      message: '请输入用户名',
      trigger: 'change'
    },
    {
      min: 5,
      message: '账号长度至少5位',
      trigger: 'blur'
    }
  ],
  password: [
    {
      required: true,
      message: '请输入密码',
      trigger: 'blur'
    },
    {
      validator: validatePass,
      trigger: 'change'
    }
  ],
  code: [
    {
      required: true,
      message: '请输入验证码',
      trigger: 'blur'
    },
    {
      validator: validateCode,
      trigger: 'change'
    }
  ]
}
